using UnityEngine;
using DG.Tweening;

public class GameOver : MonoBehaviour
{
    public GameObject gameOver;
    bool isGameOver = false;
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (isGameOver) return;
        if (other.CompareTag("Enemy"))
        {
            AudioManager.Instance.PlaySFX("失败");
            gameOver.SetActive(true);
            Camera.main.DOShakeRotation(1f, 1f, 10, 0.5f, false);
            //慢慢变大动画效果
            gameOver.transform.DOScale(Vector3.one, 2f).From(Vector3.zero);
            GameManager.Instance.isStart = false;
            isGameOver = true;
            Invoke("ShowPanel", 2f);
        }
    }

    void ShowPanel()
    {
        UI.BasePanel basePanel = UI.UIManager.Instance.OpenPanel(UI.UIConst.MenuPanel);
        basePanel.GetComponent<UI.MenuPanel>().btnCancel.interactable = false;
    }
}